package com.cb.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.cb.mapper.TUserMapper;
import com.cb.mapper.UserComboMapper;
import com.cb.wxy.pojo.CouoponsUser;
import com.cb.service.ComboMidService;
import com.cb.mapper.ComboMidMapper;
import com.jia.entity.ComboMid;
import com.jia.vo.ComBoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 卫相阳
* @description 针对表【t_combo_mid】的数据库操作Service实现
* @createDate 2024-04-25 20:40:49
*/
@Service
public class ComboMidServiceImpl extends ServiceImpl<ComboMidMapper, ComboMid>
    implements ComboMidService{

    @Autowired
    private ComboMidMapper comboMidMapper;
    @Autowired
    private TUserMapper userManager;
    @Autowired
    private UserComboMapper userComboMapper;

    @Override
    public Integer getMoney(Integer cid, Integer tid, Integer vid, Integer state) {
        System.out.println("cid:"+cid+"tid:"+tid+"vid:"+vid+"state:"+state);
        return this.comboMidMapper.getMoney(cid,tid,vid,state);
    }

    @Override
    public boolean buy(Integer id, Integer money) {
        Integer cid = this.comboMidMapper.getMoneys(money);
        if(cid==null){
            return false;
        }
        System.out.println(1+"《---用户 套餐---》"+cid);
        this.userComboMapper.inserts(id, cid);
        return true;
    }

    @Override
    public ComBoVo find(String id) {
        return comboMidMapper.find(id);
    }

    @Override
    public boolean getId(Integer id) {
        return this.userManager.getId(id);
    }

    @Override
    public List<CouoponsUser> getUidCid(Integer id) {
        return null;
    }

    @Override
    public void updateByIdByinted(Integer id, Integer integral) {
        System.out.println("id:"+id+"要扣除的积分:"+integral);
        this.userManager.updateByIdByinted(id,integral);
    }

    @Override
    public boolean updateByIdByintegral(Integer id, Integer integral) {
      return  this.userManager.updateByIdByintegral(id,integral);
    }

}




